//
//  SQAcceptanceViewController.m
//  energy
//
//  Created by 周曼迪 on 2021/7/8.
//

#import "SQAcceptanceViewController.h"

#import "SQAcceptanceModel.h"

#import "SQAcceptanceLookViewController.h"

@interface SQAcceptanceViewController ()<BaseTableVCInterface>

@end

@implementation SQAcceptanceViewController

- (void)viewDidLoad {
    self.tableViewInterface = self;
    [super viewDidLoad];
    self.navigationItem.title = @"隐患验收";
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getAcceptanceData) name:@"list" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getAcceptanceData) name:@"acceptance" object:nil];
    
    [self getAcceptanceData];
    LC_WEAK_SELF
    self.cellTitleIndex = ^(NSString * str, int key) {
        SQAcceptanceModelData * dataModel = weakSelf.dataSouece[key];
        if ([str isEqualToString:@"confirm"]) {
            SQAcceptanceLookViewController * scceptanceLookVC = SQAcceptanceLookViewController.new;
            scceptanceLookVC.hd_id = dataModel.hd_id;
            scceptanceLookVC.type = @"2";
            [weakSelf pushVC:scceptanceLookVC];
            
            
        }else if ([str isEqualToString:@"look"]){
            SQAcceptanceLookViewController * scceptanceLookVC = SQAcceptanceLookViewController.new;
            scceptanceLookVC.hd_id = dataModel.hd_id;
            scceptanceLookVC.type = @"1";
            [weakSelf pushVC:scceptanceLookVC];
            
        }else if ([str isEqualToString:@"del"]){
        }
    };
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self getAcceptanceData];
    }];
    
}

-(void)getAcceptanceData{
    [SQAcceptanceModel getDataWithParams:@{@"hd_acceptor_id":UID,@"hd_enterprise":MEnterpriseId}  WithCallBack:^(SQAcceptanceModel * data) {
        [self detailModelwithArr:data.data withCallBack:nil];
        [self reloadTableView];
    }];
}



-(BaseModel *)modelForCell:(NSIndexPath *)indexPath{
    return self.dataSouece[indexPath.row];
}



-(NSInteger)rowsCount:(NSInteger)section{
    return self.dataSouece.count;
}


- (NSArray<NSArray<NSString *> *> *)classArr{
    return @[@[@"SQConfirmTableViewCell"]];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
